home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Lines Curves and Area Fills / FillModesOddity / FillModesOddity.cs next >
Encoding:
Text File  |  2001-01-15  |  1.5 KB  |  42 lines

  1. //----------------------------------------------
  2. // FillModesOddity.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class FillModesOddity: PrintableForm
  10. {
  11.      public new static void Main()
  12.      {
  13.           Application.Run(new FillModesOddity());
  14.      }
  15.      public FillModesOddity()
  16.      {
  17.           Text = "Alternate and Winding Fill Modes (An Oddity)";
  18.           ClientSize = new Size(2 * ClientSize.Height, ClientSize.Height);
  19.      }
  20.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  21.      {
  22.           Brush    brush = new SolidBrush(clr);
  23.           PointF[] aptf = { new PointF(0.1f, 0.7f), new PointF(0.5f, 0.7f),
  24.                             new PointF(0.5f, 0.1f), new PointF(0.9f, 0.1f),
  25.                             new PointF(0.9f, 0.5f), new PointF(0.3f, 0.5f),
  26.                             new PointF(0.3f, 0.9f), new PointF(0.7f, 0.9f),
  27.                             new PointF(0.7f, 0.3f), new PointF(0.1f, 0.3f)};
  28.           
  29.           for (int i = 0; i < aptf.Length; i++)
  30.           {
  31.                aptf[i].X *= cx / 2;
  32.                aptf[i].Y *= cy;
  33.           }
  34.           grfx.FillPolygon(brush, aptf, FillMode.Alternate);
  35.  
  36.           for (int i = 0; i < aptf.Length; i++)
  37.                aptf[i].X += cx / 2;
  38.  
  39.           grfx.FillPolygon(brush, aptf, FillMode.Winding);
  40.      }
  41. }
  42.